package com.xayy.health.core.enums;

import lombok.Getter;

/**
 * @author Nie
 * @version V1.0
 * @date 2023/6/6 15:54
 */
public enum FaultFrequentEnum {
    //常驻
    RESIDENT("resident", "常驻", 40, Integer.MIN_VALUE),
    //频发
    OCCUR_FREQUENTLY("occur_frequently", "频发", 20, 40),
    //偶发
    ACCIDENTAL("accidental", "偶发", Integer.MIN_VALUE, 20);

    @Getter
    private String key;

    @Getter
    private String name;

    @Getter
    private Integer min;

    @Getter
    private Integer max;

    FaultFrequentEnum(String key, String name, Integer min, Integer max) {
        this.key = key;
        this.name = name;
        this.min = min;
        this.max = max;
    }

    public static String getKeyName(Integer num) {
        for (FaultFrequentEnum faultFrequentEnum : values()) {
            int min = faultFrequentEnum.min.compareTo(num);
            int max = faultFrequentEnum.max.compareTo(num);
            if (min <= 0 && max == 1) {
                return faultFrequentEnum.key;
            }
        }
        return "";
    }

}
